package com.example.safelib.adapter


import android.graphics.Color
import android.util.Log

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

import com.example.safelib.R
import com.example.safelib.bean.SafeSenSorBean

class SafeListAdapter(layoutResId: Int) :
    BaseQuickAdapter<SafeSenSorBean, BaseViewHolder>(layoutResId) {

    override fun convert(helper: BaseViewHolder, item: SafeSenSorBean) {

        if(item.statusdec=="正常"){
            helper.setTextColor(R.id.safe_list_stats,Color.parseColor("#222222"))
        }
        if (item.statusdec=="异常"){
            helper.setTextColor(R.id.safe_list_stats,Color.parseColor("#FF6600"))
        }

        helper.setText(
            R.id.safe_list_sensor,
            (helper.position + 1).toString() + " " + "-" + " " + item.sensorname
        )
            .setText(R.id.safe_list_no, item.sensornum)
            .setText(R.id.safe_list_local, item.sensorplace)
            .setText(R.id.safe_list_value, item.realvalue.toString() + "" + (item.sensorunit ?: ""))
            .setText(R.id.safe_list_stats, item.statusdec)

    }


}
